from typing import List


class Solution:
    def minEatingSpeed(self, piles: List[int], h: int) -> int:
        low = int(min(piles) / int(h / len(piles)))
        high = int(max(piles) / int(h / len(piles))) + 1
        print(low, high)
        while low < high:
            mid = (low + high) // 2  # 假设速度为mid
            cur = 0
            if mid == 0:
                return 1
            for pile in piles:

                x, y = divmod(pile, mid)
                if y:
                    x += 1
                cur += x

            print(mid, low, high, cur)
            if cur > h:  # 分的太小
                low = mid + 1
            else:
                high = mid

        return high
